package secondStage.part5.网络编程.TCP通信程序;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @ClassName: [ServerTcpReceiveTest]
 * @Description: TCP通信程序，接收信息
 * @Author: [黄劲松]
 * @CreateDate: [2021-04-06]
 * @Version: [v1.0]
 */
//服务器:接收数据输出
public class ServerTcpReceiveTest1 {
    public static void main(String[] args) throws IOException {
        //创建, 服务器端的Socket对象(ServerSocket)
        ServerSocket ss = new ServerSocket (8080);
        //监听客户端连接，返回一个Socket对象
        Socket s = ss.accept();
        //获取输入流，读数据，并把数据显示在控制台
//        InputStream is = s.getInputStream();
//        InputStreamReader isr = new InputStreamReader(is);
//        BufferedReader br = new BufferedReader(isr);
        BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String line;
        while ((line=br.readLine())!=null){
            System.out.println(line);
        }
        //释放资源.
        ss.close();
    }
}
